// components/my-navBar/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    offsetTop: {
      type: Number,
      value: 0
    },
    leftICon: {
      type: Boolean,
      value: true
    },
    pageData: {},
    title: {
      type: String,
      value: "OA"
    },
    info: {
      type: Boolean,
      value: false
    },
    showData: {
      type: Boolean,
      value: true
    },
    showColor: {
      type: Boolean,
      value: false
    }
  },
  lifetimes: {
    ready() {
      this.data.info && this.createSelectorQuery().select("#myNavBar").boundingClientRect((res => {
        this.triggerEvent('info', res);
      })).exec()
    }
  },
  /**
   * 组件的方法列表
   */
  methods: {
    back() {
      /*       let pages = getCurrentPages();
            let prevPage = pages[pages.length - 1];
            console.log(prevPage)
            if (prevPage.route == 'pagesDoctor/messageDetail/index') {
              wx.redirectTo({
                url: '/pagesDoctor/doctorIndex/index',
              })
            } */


      if (this.data.pageData == '药品支付') {
        let pages = getCurrentPages();
        let prevPage = pages[pages.length - 2];
        if (prevPage.route == 'pages/drugRecord/index') {
          /* wx.navigateBack() */
        } else {
          wx.navigateBack({
            delta: 2
          })
        }
      }

      wx.navigateBack({
        fail: () => {
          wx.reLaunch({
            url: '/pages/index/index',
          })
        }
      })
    }
  }
})